package com.example.userservice.novel.entity;

/**
 * 生成响应
 */
public class NovelGenerateResponse {
    private boolean success;
    private NovelStructure novelStructure;
    private String errorMessage;
    private Long generateTime; // 生成耗时(ms)
    
    public static NovelGenerateResponse success(NovelStructure structure, Long generateTime) {
        return NovelGenerateResponse.builder()
                .success(true)
                .novelStructure(structure)
                .generateTime(generateTime)
                .build();
    }
    
    public static NovelGenerateResponse error(String errorMessage) {
        return NovelGenerateResponse.builder()
                .success(false)
                .errorMessage(errorMessage)
                .build();
    }
    
    // Builder模式方法
    public static Builder builder() {
        return new Builder();
    }
    
    public static class Builder {
        private boolean success;
        private NovelStructure novelStructure;
        private String errorMessage;
        private Long generateTime;
        
        public Builder success(boolean success) {
            this.success = success;
            return this;
        }
        
        public Builder novelStructure(NovelStructure novelStructure) {
            this.novelStructure = novelStructure;
            return this;
        }
        
        public Builder errorMessage(String errorMessage) {
            this.errorMessage = errorMessage;
            return this;
        }
        
        public Builder generateTime(Long generateTime) {
            this.generateTime = generateTime;
            return this;
        }
        
        public NovelGenerateResponse build() {
            NovelGenerateResponse response = new NovelGenerateResponse();
            response.success = this.success;
            response.novelStructure = this.novelStructure;
            response.errorMessage = this.errorMessage;
            response.generateTime = this.generateTime;
            return response;
        }
    }
    
    // Getter方法
    public boolean isSuccess() {
        return success;
    }

    public NovelStructure getNovelStructure() {
        return novelStructure;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public Long getGenerateTime() {
        return generateTime;
    }

    // Setter方法
    public void setSuccess(boolean success) {
        this.success = success;
    }

    public void setNovelStructure(NovelStructure novelStructure) {
        this.novelStructure = novelStructure;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public void setGenerateTime(Long generateTime) {
        this.generateTime = generateTime;
    }
}